package com.xfxz.merchant.view.coupon;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.Button;

import com.xfxz.merchant.R;
import com.xfxz.merchant.adapter.ViewPagerAdapter;
import com.xfxz.merchant.fragment.CouponListFragment;
import com.xfxz.merchant.myapplication.BaseActivity;
import com.xfxz.merchant.view.MainView;

import java.util.ArrayList;
import java.util.List;

public class CouponManagerActivity extends BaseActivity implements MainView, View.OnClickListener {

    private Button mBtnCouponAddcoupon;
    private TabLayout mTablCouponPagertitle;
    private ViewPager mVpCouponCouponpager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        BaseSetContentView(R.layout.activity_coupon_manager);
        initView();
        initViewPager();
    }

    private void initViewPager() {
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(CouponListFragment.newInstance("0",""));
        fragments.add(CouponListFragment.newInstance("1",""));
        fragments.add(CouponListFragment.newInstance("2",""));
        String[] titles = new String[]{"可领用","已领完","已过期"};
        ViewPagerAdapter mAdapter = new ViewPagerAdapter(getSupportFragmentManager(), fragments, titles);
        mVpCouponCouponpager.setAdapter(mAdapter);
    }

    private void initView() {
        setTitle(getString(R.string.title_coupon));
        setBarBackgroundColor(getResources().getColor(R.color.colorWhite));
        isBarBackShow(true);
        mBtnCouponAddcoupon = (Button) findViewById(R.id.btn_coupon_addcoupon);
        mTablCouponPagertitle = (TabLayout) findViewById(R.id.tabl_coupon_pagertitle);
        mVpCouponCouponpager = (ViewPager) findViewById(R.id.vp_coupon_couponpager);
        mTablCouponPagertitle.setupWithViewPager(mVpCouponCouponpager);

        mVpCouponCouponpager.setOnClickListener(this);
        mBtnCouponAddcoupon.setOnClickListener(this);
        mTablCouponPagertitle.setOnClickListener(this);
    }

    @Override
    public void onBarBackClickListener() {
        finish();
    }

    @Override
    public void setData(Object o) {

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_coupon_addcoupon:

                break;
        }
    }
}
